/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package UI;

import Data.DataManager;
import static Data.DataManager.searchData;
import HangHoa.*;
import static UI.MainMN.PanelHH;
import java.lang.String;
import java.util.Vector;
import javax.swing.JOptionPane;

/**
 *
 * @author Tuan
 */
public class PanelEdit extends javax.swing.JPanel {

    /**
     * Creates new form PannelEdit
     */
    public PanelEdit() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroupMode = new javax.swing.ButtonGroup();
        jPanelMode = new javax.swing.JPanel();
        jToggleButtonThem = new javax.swing.JToggleButton();
        jToggleButtonUpdate = new javax.swing.JToggleButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jTextName = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextNhaSX = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jTextGiaNhap = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jTextGiaBan = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jTextSL = new javax.swing.JTextField();
        jComboBoxType = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jTextChatLieu = new javax.swing.JTextField();
        jLabelX = new javax.swing.JLabel();
        jTextX = new javax.swing.JTextField();
        jLabelY = new javax.swing.JLabel();
        jTextY = new javax.swing.JTextField();
        jLabelZ = new javax.swing.JLabel();
        jTextZ = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jButtonThem = new javax.swing.JButton();
        jButtonSua = new javax.swing.JButton();

        setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        buttonGroupMode.add(jToggleButtonThem);
        jToggleButtonThem.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jToggleButtonThem.setText("Thêm mặt hàng");
        jToggleButtonThem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButtonThemActionPerformed(evt);
            }
        });

        buttonGroupMode.add(jToggleButtonUpdate);
        jToggleButtonUpdate.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jToggleButtonUpdate.setSelected(true);
        jToggleButtonUpdate.setText("Cập nhật");
        jToggleButtonUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButtonUpdateActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelModeLayout = new javax.swing.GroupLayout(jPanelMode);
        jPanelMode.setLayout(jPanelModeLayout);
        jPanelModeLayout.setHorizontalGroup(
            jPanelModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToggleButtonThem, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jToggleButtonUpdate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanelModeLayout.setVerticalGroup(
            jPanelModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelModeLayout.createSequentialGroup()
                .addComponent(jToggleButtonThem, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jToggleButtonUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setText("Mặt hàng* :");

        jLabel2.setText("Loại hàng* :");

        jLabel3.setText("Nhà sản xuất* :");

        jLabel4.setText("Giá nhập* :");

        jLabel5.setText("Giá bán*:");
        jLabel5.setToolTipText("");

        jLabel6.setText("Số lượng hiện có*:");

        jTextSL.setEditable(false);
        jTextSL.setBackground(new java.awt.Color(240, 240, 240));

        jComboBoxType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Quần", "Áo", "Giầy" }));
        jComboBoxType.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxTypeActionPerformed(evt);
            }
        });

        jLabel7.setText("Chất liệu:");

        jLabelX.setText("jLabel8");

        jLabelY.setText("jLabel9");

        jLabelZ.setText("jLabel10");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jLabelZ, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabelY, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabelX, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jTextName)
                    .addComponent(jTextNhaSX)
                    .addComponent(jTextGiaNhap)
                    .addComponent(jTextGiaBan)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jComboBoxType, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextChatLieu, javax.swing.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE))
                    .addComponent(jTextSL)
                    .addComponent(jTextX)
                    .addComponent(jTextY)
                    .addComponent(jTextZ))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(2, 2, 2)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextName, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jComboBoxType, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTextChatLieu, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextNhaSX, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextGiaNhap, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextGiaBan, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextSL, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelX, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextX, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelY, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextY, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelZ, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextZ, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButtonThem.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jButtonThem.setText("Thêm");
        jButtonThem.setPreferredSize(new java.awt.Dimension(51, 90));
        jButtonThem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonThemActionPerformed(evt);
            }
        });

        jButtonSua.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jButtonSua.setText("Sửa");
        jButtonSua.setPreferredSize(new java.awt.Dimension(51, 90));
        jButtonSua.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSuaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButtonThem, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonSua, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(164, 164, 164))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButtonThem, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButtonSua, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanelMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanelMode, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jToggleButtonUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonUpdateActionPerformed
      jButtonSua.setVisible(true);
      jButtonThem.setVisible(false);
      jComboBoxType.setEditable(false);
    }//GEN-LAST:event_jToggleButtonUpdateActionPerformed

    private void jToggleButtonThemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonThemActionPerformed
        jComboBoxType.setEditable(true);
        jButtonSua.setVisible(false);
       jButtonThem.setVisible(true);
       newData();
    }//GEN-LAST:event_jToggleButtonThemActionPerformed

    private void jComboBoxTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxTypeActionPerformed
        newData();// TODO add your handling code here:
    }//GEN-LAST:event_jComboBoxTypeActionPerformed
 String constDonVi[] = new String[]{"Chiếc","Chiếc","Đôi"};
    private void jButtonSuaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSuaActionPerformed
        String sSP[] = new String[11];
        sSP[0]=memoryID;
        sSP[1]=(jTextName.getText());
        sSP[2]=(jTextNhaSX.getText());
        sSP[3]=(jTextChatLieu.getText());
        sSP[4]=(jTextGiaNhap.getText());
        sSP[5]=(jTextGiaBan.getText());
        sSP[6]=(jTextSL.getText());
        sSP[7]=(constDonVi[jComboBoxType.getSelectedIndex()]);
        sSP[8]=(jTextX.getText());
        sSP[9]=(jTextY.getText());
        sSP[10]=(jTextZ.getText());
        DataManager.updateData(sSP);
        SanPham sP=DataManager.convertToSP(sSP);
        PanelHH.Update(sP,true);
        JOptionPane.showMessageDialog(jPanel2,"Done");
    }//GEN-LAST:event_jButtonSuaActionPerformed

    private void jButtonThemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonThemActionPerformed
        String sSP[] = new String[11];
        NewID(jComboBoxType.getSelectedIndex());
        sSP[0]=memoryID;
        sSP[1]=(jTextName.getText());
        sSP[2]=(jTextNhaSX.getText());
        sSP[3]=(jTextChatLieu.getText());
        sSP[4]=(jTextGiaNhap.getText());
        sSP[5]=(jTextGiaBan.getText());
        sSP[6]=(jTextSL.getText());
        sSP[7]=(constDonVi[jComboBoxType.getSelectedIndex()]);
        sSP[8]=(jTextX.getText());
        sSP[9]=(jTextY.getText());
        sSP[10]=(jTextZ.getText());
        DataManager.newtoData(sSP);
        SanPham sP=DataManager.convertToSP(sSP);
        PanelHH.Update(sP,false);
        JOptionPane.showMessageDialog(jPanel2,"Done");
    }//GEN-LAST:event_jButtonThemActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroupMode;
    private javax.swing.JButton jButtonSua;
    private javax.swing.JButton jButtonThem;
    private javax.swing.JComboBox jComboBoxType;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabelX;
    private javax.swing.JLabel jLabelY;
    private javax.swing.JLabel jLabelZ;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanelMode;
    private javax.swing.JTextField jTextChatLieu;
    private javax.swing.JTextField jTextGiaBan;
    private javax.swing.JTextField jTextGiaNhap;
    private javax.swing.JTextField jTextName;
    private javax.swing.JTextField jTextNhaSX;
    private javax.swing.JTextField jTextSL;
    private javax.swing.JTextField jTextX;
    private javax.swing.JTextField jTextY;
    private javax.swing.JTextField jTextZ;
    private javax.swing.JToggleButton jToggleButtonThem;
    private javax.swing.JToggleButton jToggleButtonUpdate;
    // End of variables declaration//GEN-END:variables
String memoryID = new String();
    void setData(String ID) {
        String sP[] = searchData(ID);
        memoryID=ID;
        if (sP[0].startsWith("QUAN")) {
            jLabelX.setText("Chiều dài");
            jLabelY.setText("Chiều rộng");
            jLabelZ.setText("Kiểu:");
            jComboBoxType.setSelectedIndex(0);
        }
        else if (sP[0].startsWith("AO")) {
            jLabelX.setText("Kiểu cổ áo");
            jLabelY.setText("Kiểu tay áo");
            jLabelZ.setText("Size:");
            jComboBoxType.setSelectedIndex(1);
        }
        else if (sP[0].startsWith("GIAY")) {
            jLabelX.setText("Kiểu đế giày");
            jLabelY.setText("Kiểu quai dây:");
            jLabelZ.setText("Size:");
            jComboBoxType.setSelectedIndex(2);
        }
        jTextName.setText(sP[1]);
        jTextNhaSX.setText(sP[2]);
        jTextChatLieu.setText(sP[3]);
        jTextGiaNhap.setText(sP[4]);
        jTextGiaBan.setText(sP[5]);
        jTextSL.setText(sP[6]);
        jTextX.setText(sP[8]);
        jTextY.setText(sP[9]);
        jTextZ.setText(sP[10]);
       
        //To change body of generated methods, choose Tools | Templates.
    }

    void newData() {
        if (jComboBoxType.getSelectedIndex()==0) {
            jLabelX.setText("Chiều dài");
            jLabelY.setText("Chiều rộng");
            jLabelZ.setText("Kiểu:");
        }
        else if (jComboBoxType.getSelectedIndex()==1) {
            jLabelX.setText("Kiểu cổ áo");
            jLabelY.setText("Kiểu tay áo");
            jLabelZ.setText("Size:");
        }
        else if (jComboBoxType.getSelectedIndex()==2) {
            jLabelX.setText("Kiểu đế giày");
            jLabelY.setText("Kiểu quai dây:");
            jLabelZ.setText("Size:");
        }
        jTextName.setText(null);
        jTextNhaSX.setText(null);
        jTextChatLieu.setText(null);
        jTextGiaNhap.setText(null);
        jTextGiaBan.setText(null);
        jTextSL.setText("0");
        jTextX.setText(null);
        jTextY.setText(null);
        jTextZ.setText(null);
        //To change body of generated methods, choose Tools | Templates.
    }

    void setMode(int i) {
        if (i==0) jToggleButtonThem.doClick();
        else jToggleButtonUpdate.doClick();//To change body of generated methods, choose Tools | Templates.
    }

    private void NewID(int selectedIndex) {
        String type[]=new String[]{"QUAN", "AO", "GIAY"};
        if (searchData(type[selectedIndex])==null){
           String numberSTR ="1";
           while (type[selectedIndex].length()+ numberSTR.length()<7) numberSTR = "0" + numberSTR;
            memoryID=type[selectedIndex]+numberSTR;
        }
        else{
            String numberSTR=searchData(type[selectedIndex])[0].replace(type[selectedIndex],"");
            int number = Integer.parseInt(numberSTR)+1;
            numberSTR=""+number;
           while (type[selectedIndex].length()+ numberSTR.length()<7) numberSTR = "0" + numberSTR;
            memoryID=type[selectedIndex]+ numberSTR;
        }
    }
}
